/*
 admin.go
 Created by hupfei on 2020-01-06
*/

package v1

import (
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
	"github.com/jmoiron/sqlx"
	"strconv"
	"time"
	"zimuzu_cvn_web_api/config"
	"zimuzu_cvn_web_api/model"
	"zimuzu_cvn_web_api/pkg/e"
	"zimuzu_cvn_web_api/pkg/errno"
	"zimuzu_cvn_web_api/router/api"
	"zimuzu_cvn_web_api/router/api/admin/middleware"
	"zimuzu_cvn_web_api/service"
	"zimuzu_cvn_web_api/service/flows"
)

type AdminAPI struct {
}

func (admin AdminAPI) Name() string {
	return "admin API"
}

func (admin AdminAPI) Bind() {
	adminAPI := config.C.Router.Group("/v1/admin", middleware.TrackLog(), middleware.AuthMiddleware())
	{
		adminAPI.POST("uploadPic", uploadPic)
		adminAPI.GET("cvnLog", cvnLog)
		adminAPI.GET("usdtLog", usdtLog)
		adminAPI.GET("shopList", shopList)
		adminAPI.POST("editShop", editShop)
		adminAPI.GET("shopOrderList", shopOrderList)
		adminAPI.POST("editShopOrder", editShopOrder)
		adminAPI.GET("newsList", newsList)
		adminAPI.POST("editNews", editNews)
		adminAPI.GET("deleteNews", deleteNews)
		adminAPI.GET("weeklyList", weeklyList)
		adminAPI.POST("editWeekly", editWeekly)
		adminAPI.GET("deleteWeekly", deleteWeekly)
		adminAPI.GET("superNodeList", superNodeList)
		adminAPI.POST("editSuperNodeInfo", editSuperNodeInfo)
		adminAPI.GET("slideshowList", slideshowList)
		adminAPI.POST("editSlideshow", editSlideshow)
		adminAPI.GET("deleteSlideshow", deleteSlideshow)
		adminAPI.GET("announcementCategoryList", announcementCategoryList)
		adminAPI.POST("editAnnouncementCategory", editAnnouncementCategory)
		adminAPI.GET("deleteAnnouncementCategory", deleteAnnouncementCategory)
		adminAPI.GET("announcementList", announcementList)
		adminAPI.POST("editAnnouncement", editAnnouncement)
		adminAPI.GET("deleteAnnouncement", deleteAnnouncement)
		adminAPI.GET("recommendAnnouncement", recommendAnnouncement)
		adminAPI.GET("cvnExamineList", cvnExamineList)
		adminAPI.GET("cvnExamineCheck", cvnExamineCheck)
		adminAPI.POST("cvnExaminePass", cvnExaminePass)
		adminAPI.POST("cvnExamineRefuse", cvnExamineRefuse)
		adminAPI.GET("usdtExamineList", usdtExamineList)
		adminAPI.GET("usdtExamineCheck", usdtExamineCheck)
		adminAPI.POST("usdtExaminePass", usdtExaminePass)
		adminAPI.POST("usdtExamineRefuse", usdtExamineRefuse)
		adminAPI.POST("sysUpdateCvn", sysUpdateCvn)
		adminAPI.GET("heatDistribution", heatDistribution)
	}
}

// 热力图
// Auth: hzp
func heatDistribution(c *gin.Context) {
	res, err := flows.GetHeatDistribution()
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "获取数据成功"
	api.SendResponse(c, errno.OK, res)
	return
}

type idParams struct {
	Id int `form:"id" binding:"required"`
}

//上传图片
func uploadPic(c *gin.Context) {
	file, err := c.FormFile("pic")
	if err != nil {
		e.Log("err", "上传图片失败：", err.Error())
		api.SendResponse(c, err, nil)
		return
	}
	saveName := time.Now().Format("20060102150405_") + file.Filename
	err = c.SaveUploadedFile(file, e.PicResourceLocal+saveName)
	if err != nil {
		e.Log("err", "上传图片失败：", err.Error())
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "上传图片成功"
	api.SendResponse(c, errno.OK, saveName)
	return
}

/*
 * @ Author: hupfei
 * @ Description:3.7.1 cvn转账日志
 **/
type cvnLogParams struct {
	model.PageParams
	Status    int     `form:"status"` //1-成功，2-失败，3-处理中
	TargetUid int     `form:"targetUid"`
	MinAmount float64 `form:"minAmount"`
	MaxAmoint float64 `form:"maxAmount"`
	Keywords  int64   `form:"keywords"`
}

func cvnLog(c *gin.Context) {
	var params cvnLogParams
	params.PageParams = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	res, err := model.GetTransferLog(params.Page, params.Per, params.Status, params.TargetUid)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	var count int
	if params.Page == 1 {
		count, _ = model.GetTransferLogCount(params.Status, params.TargetUid)
		errno.OK.Info = strconv.Itoa(count)
	} else {
		errno.OK.Info = "成功"
	}

	api.SendResponse(c, errno.OK, res)
	return
}

type usdtLogParams struct {
	model.PageParams
	Status    int `form:"status"` //1-成功，2-失败，3-处理中
	TargetUid int `form:"targetUid"`
}

func usdtLog(c *gin.Context) {
	var params cvnLogParams
	params.PageParams = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	res, err := model.GetUsdtTransferLog(params.Page, params.Per, params.Status, params.TargetUid)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	var count int
	if params.Page == 1 {
		count, _ = model.GetUsdtTransferLogCount(params.Status, params.TargetUid)
		errno.OK.Info = strconv.Itoa(count)
	} else {
		errno.OK.Info = "成功"
	}

	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 商品列表
 **/
func shopList(c *gin.Context) {
	var params model.PageParams
	params = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	res, err := model.GetShopList(params.Page, params.Per)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description:  编辑/新增商品
 **/
func editShop(c *gin.Context) {
	var params model.EditShopParams
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	if params.GId > 0 {
		err = model.EditShop(params)
	} else {
		err = model.AddNewShop(params)
	}
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 订单列表
 **/
func shopOrderList(c *gin.Context) {
	var params model.ShopOrderListParams
	params.PageParams = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	res, err := model.ListShopOrder(params)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	var count int
	if params.Page == 1 {
		count, _ = model.GetShopOrderCount(params)
		errno.OK.Info = strconv.Itoa(count)
	} else {
		errno.OK.Info = "成功"
	}
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 修改订单信息
 **/
func editShopOrder(c *gin.Context) {
	var params model.EditShopOrderParams
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.EditShopOrder(params)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 新闻列表
 **/
type newsListParams struct {
	model.PageParams
	Language string `form:"language"`
}

func newsList(c *gin.Context) {
	var params newsListParams
	params.PageParams = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	res, err := model.GetNewsListFromDB(config.C.DB.DB, params.Per, params.Page, params.Language)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 编辑/新增新闻
 **/
func editNews(c *gin.Context) {
	var params model.NewsInfo
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	if params.Id > 0 {
		err = model.UpdateNews(params)
	} else {
		err = model.AddNewNews(params)
	}

	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 删除新闻
 **/
func deleteNews(c *gin.Context) {
	var params idParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.DeleteNews(params.Id)
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 新闻列表
 **/
func weeklyList(c *gin.Context) {
	var params model.PageParams
	params = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	res, err := model.GetWeeklyListFromDB(config.C.DB.DB, params.Per, params.Page)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 编辑/新增周报
 **/
func editWeekly(c *gin.Context) {
	var params model.WeeklyInfo
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	if params.Id > 0 {
		err = model.UpdateWeekly(params)
	} else {
		err = model.AddNewWeekly(params)
	}

	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 删除新闻
 **/
func deleteWeekly(c *gin.Context) {
	var params idParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.DeleteWeekly(params.Id)
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

type superNodeOne struct {
	NodeId int64 `db:"super_node_id"`
	Count  int   `db:"count"`
}

type superNodeTwo struct {
	NodeId int64   `db:"super_node_id"`
	Amount float64 `db:"amount"`
}

/*
 * @ Author: hupfei
 * @ Description: 超级节点列表
 **/
func superNodeList(c *gin.Context) {
	res, err := model.GetSuperNodeList()
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}
	//遍历超级节点 旗下节点数
	var nodeNumStruct []superNodeOne
	err = sqlx.Select(config.C.DB.DB, &nodeNumStruct, "SELECT super_node_id,count(n.uid) count from mg_node n LEFT JOIN super_node_miner m ON m.uid = n.uid where m.`status` = 20 GROUP BY m.super_node_id")
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	nodeNum := make(map[int64]int, 0)
	for _, node := range nodeNumStruct {
		nodeNum[node.NodeId] = node.Count
	}
	//遍历超级节点收益
	var nodeIncomeStruct []superNodeTwo
	err = sqlx.Select(config.C.DB.DB, &nodeIncomeStruct, "SELECT super_node_id, sum(super_cvn) amount FROM mg_node_payment  GROUP BY super_node_id ")
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	nodeIncome := make(map[int64]float64, 0)
	for _, node := range nodeIncomeStruct {
		nodeIncome[node.NodeId] = node.Amount
	}

	for k, node := range res {
		if _, ok := nodeNum[node.NodeId]; ok {
			res[k].NodesNum = nodeNum[node.NodeId]
		}
		if _, ok := nodeIncome[node.NodeId]; ok {
			res[k].IncomeTotal = nodeIncome[node.NodeId]
		}
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 新增/编辑超级节点信息
 **/
func editSuperNodeInfo(c *gin.Context) {
	var params model.AdminSuperNodeInfo
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	e.Log("params", "编辑超级节点信息", params)
	if params.NodeId > 0 {
		err = model.UpdateSuperNodeInfo(params)
	} else {
		//校验短信验证码
		//if errValid := service.ValidateCode(e.AdminPhone2, service.AddSuperNode, params.Code); errValid != nil {
		//	api.SendResponse(c, err, nil)
		//	return
		//}
		err = model.AddNewSuperNode(params)
	}

	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 轮播图列表
 **/
type slideshowListParams struct {
	model.PageParams
	Module int `form:"module"`
}

func slideshowList(c *gin.Context) {
	var params slideshowListParams
	params.PageParams = model.NewDefaultPageParams()
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	res, err := model.GetAllSlideshowList(params.Module, params.Page, params.Per)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 新增/编辑轮播图
 **/
func editSlideshow(c *gin.Context) {
	var params model.SlideshowDB
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	uid, _ := service.GetUserIdByRequest(c)
	if params.ID > 0 {
		err = model.UpdateSlideshow(uid, params)
	} else {
		err = model.AddNewSlideshow(uid, params)
	}
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 删除轮播图
 **/
func deleteSlideshow(c *gin.Context) {
	var params idParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.DeleteSlideshow(params.Id)
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 公告分类列表
 **/
func announcementCategoryList(c *gin.Context) {
	res, err := model.GetAnnouncementCategoryList()
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 新增/编辑公告分类
 **/
func editAnnouncementCategory(c *gin.Context) {
	var params model.AnnouncementCategory
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	if params.ID > 0 {
		err = model.UpdateNewAnnouncementCategory(params.ID, params.Name)
	} else {
		err = model.AddNewAnnouncementCategory(params.Name)
	}
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 删除公告分类
 **/
func deleteAnnouncementCategory(c *gin.Context) {
	var params idParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.DeleteAnnouncementCategory(params.Id)
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 公告列表
 **/
func announcementList(c *gin.Context) {
	var params model.PageParams
	params = model.NewDefaultPageParams()
	res, err := model.GetALLAnnouncementList(params)
	if err != nil {
		api.SendResponse(c, errno.DbSearchError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, res)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 新增/编辑公告
 **/
func editAnnouncement(c *gin.Context) {
	var params model.AnnouncementAdmin
	err := c.ShouldBindWith(&params, binding.FormPost)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	if params.ID > 0 {
		err = model.UpdateAnnouncement(params)
	} else {
		err = model.AddNewAnnouncement(params)
	}
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 删除公告
 **/
func deleteAnnouncement(c *gin.Context) {
	var params idParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.DeleteAnnouncement(params.Id)
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

/*
 * @ Author: hupfei
 * @ Description: 公告推荐/取消推荐到首页
 **/
func recommendAnnouncement(c *gin.Context) {
	var params idParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}

	err = model.RecommendAnnouncement(params.Id)
	if err != nil {
		api.SendResponse(c, errno.DbError, nil)
		return
	}

	errno.OK.Info = "成功"
	api.SendResponse(c, errno.OK, nil)
	return
}

//审核列表
func cvnExamineList(c *gin.Context) {
	var params cvnLogParams
	params.PageParams = model.NewDefaultPageParams()
	if err := c.ShouldBindWith(&params, binding.Query); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	data, err := service.CvnExamineList(params.PageParams.Page, params.PageParams.Per, params.Status, params.Keywords, params.MinAmount, params.MaxAmoint)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, data)
	return
}

//检查审核项
func cvnExamineCheck(c *gin.Context) {
	var params model.IdParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	data, _, err := service.CvnExamineCheck(params.Id)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, data)
	return
}

//审核通过
func cvnExaminePass(c *gin.Context) {
	var params model.IdParams
	uid, _ := service.GetUserIdByRequest(c)
	if err := c.ShouldBindWith(&params, binding.FormPost); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	err := service.CvnExaminePass(params.Id, uid)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, nil)
	return
}

//审核不通过
func cvnExamineRefuse(c *gin.Context) {
	var params model.IdParams
	uid, _ := service.GetUserIdByRequest(c)
	if err := c.ShouldBindWith(&params, binding.FormPost); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	err := service.CvnExamineRefuse(params.Id, uid)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, nil)
	return
}

//审核列表
func usdtExamineList(c *gin.Context) {
	var params cvnLogParams
	params.PageParams = model.NewDefaultPageParams()
	if err := c.ShouldBindWith(&params, binding.Query); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	data, err := service.UsdtExamineList(params.PageParams.Page, params.PageParams.Per, params.Status)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, data)
	return
}

//检查审核项
func usdtExamineCheck(c *gin.Context) {
	var params model.IdParams
	err := c.ShouldBindWith(&params, binding.Query)
	if err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	data, _, err := service.UsdtExamineCheck(params.Id)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, data)
	return
}

//审核通过
func usdtExaminePass(c *gin.Context) {
	var params model.IdParams
	uid, _ := service.GetUserIdByRequest(c)
	if err := c.ShouldBindWith(&params, binding.FormPost); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	err := service.UsdtExaminePass(params.Id, uid)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, nil)
	return
}

//审核不通过
func usdtExamineRefuse(c *gin.Context) {
	var params model.IdParams
	uid, _ := service.GetUserIdByRequest(c)
	if err := c.ShouldBindWith(&params, binding.FormPost); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	err := service.UsdtExamineRefuse(params.Id, uid)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, nil)
	return
}

//内部充值/扣除
func sysUpdateCvn(c *gin.Context) {
	var params model.SysCvnParams
	if err := c.ShouldBindWith(&params, binding.FormPost); err != nil {
		api.SendResponse(c, errno.ParamsError, nil)
		return
	}
	err := service.SysUpdateCvn(params)
	if err != nil {
		api.SendResponse(c, err, nil)
		return
	}
	errno.OK.Info = "OK"
	api.SendResponse(c, errno.OK, nil)
	return
}
